package com.five.community.service.impl;

import com.five.community.bean.Asset;
import com.five.community.bean.vo.AssetVo;
import com.five.community.mapper.AssetMapper;
import com.five.community.service.AssetService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssetServiceImpl implements AssetService{
    @Autowired
    private AssetMapper assetMapper;

    @Override
    public List<AssetVo> selectAll() throws Exception {
        return assetMapper.selectAll();
    }

    @Override
    public void deleteById(long id) throws Exception {
        assetMapper.deleteById(id);
    }

    @Override
    public void insert(Asset asset) throws Exception {
        assetMapper.insert(asset);
    }

    @Override
    public List<AssetVo> selectByName(String name) throws Exception {
        return assetMapper.selectByName(name);
    }

    @Override
    public Asset selectById(long id) throws Exception {
        return assetMapper.selectById(id);
    }

    @Override
    public void update(Asset asset) throws Exception {
        assetMapper.update(asset);
    }

    @Override
    public List<AssetVo> selectAllAssets(Integer pageNum, Integer pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return assetMapper.selectAll();
    }

    @Override
    public List<AssetVo> selectAllByName(Integer pageNum, Integer pageSize, String name) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return assetMapper.selectByName(name);
    }
}
